var mysql = require('mysql'),
config = require('../config/config'),
/*
connectionPool = mysql.createPool({
    host     : 'localhost',
    user     : 'root',
    password : 'yuhuaren',
    database : 'ltms'
});
*/
connectionPool = mysql.createPool({
    host     : '10.4.3.92',
    user     : 'u5VOfyk4eQbmS',
    password : 'p4u8wLc4WRwtS',
    database : 'de65eb86b39204d569ce3e757a3e94a64',
    port     : '3306'
});

exports.query = function(sql, params, fn) {
    connectionPool.getConnection(function(error, connection) {
        if (error) {
            fn(error);
            return;
        }
        connection.query(sql, params, function(error, rows) {
            connection.release();
            if (error) {
                fn(error);
                return;
            }
            fn(null, rows);
        });
    });
};

exports.getConnection = function(fn) {
    connectionPool.getConnection(fn);
};